from zope.component import adapter, getUtility, getMultiAdapter, getUtilitiesFor
from zope.app.container.interfaces import INameChooser
from zope.exceptions import DuplicationError

from Acquisition import aq_inner, aq_parent
from plone.portlets.interfaces import IPortletManager , IPortletAssignmentMapping


from Products.tchezope_tema.browser.interfaces import ITchezopeLoginBarPortletManager 
from Products.tchezope_tema.browser.login import Assignment




def install(context):
    site = context.getSite()
    manager = getUtility(IPortletManager,name=u'tchezope.loginbar_manager')
    assigmentMapping = getMultiAdapter((site,manager,),IPortletAssignmentMapping)
    assigment = Assignment()
    #chooser = INameChooser(assigmentMapping)
    try:
        assigmentMapping['loginbar'] = assigment
    except DuplicationError:
        pass
